package org.adream.account.service.cloudCollege;

import javax.annotation.Resource;

import org.adream.account.util.HttpClientUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSONObject;

/**
 * 同步真爱云学院信息
 * @author sl
 *
 */
@Component
@EnableAsync
public class SynCloudCollegeService {

	@Resource
	private TaskExecutor taskExecutor;
	
	@Value("${cloud.college.userUpdateUrl}")
	private String updateUserUrl;
	
	@Async
	public void synLibraryUser(SynCloudCollegeUserEntity cloudCollegeUser) {
		String json = JSONObject.toJSONString(cloudCollegeUser);
		taskExecutor.execute(new Runnable() {
			@Override
			public void run() {
				HttpClientUtil.httpJsonStringPost(updateUserUrl, json);
			}
		});
	}
}